home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16615 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  1.7 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news text default
99% file C++ source text default
98% file C++ source, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 68 6f | 6d 65 6e 65 74 2e 68 6f |Path: ho|menet.ho|
|00000010| 6d 2e 6e 65 74 21 6e 6e | 61 64 6d 69 6e 40 68 6f |m.net!nn|admin@ho|
|00000020| 6d 2e 6e 65 74 0a 46 72 | 6f 6d 3a 20 64 65 6e 67 |m.net.Fr|om: deng|
|00000030| 65 6c 40 68 6f 6d 2e 6e | 65 74 20 28 44 61 6e 69 |el@hom.n|et (Dani|
|00000040| 65 6c 20 50 2e 20 45 6e | 67 65 6c 20 49 49 49 29 |el P. En|gel III)|
|00000050| 0a 4e 65 77 73 67 72 6f | 75 70 73 3a 20 63 6f 6d |.Newsgro|ups: com|
|00000060| 70 2e 6c 61 6e 67 2e 63 | 2b 2b 0a 53 75 62 6a 65 |p.lang.c|++.Subje|
|00000070| 63 74 3a 20 46 72 69 65 | 6e 64 20 76 73 2e 20 4d |ct: Frie|nd vs. M|
|00000080| 65 6d 62 65 72 20 66 75 | 6e 63 74 69 6f 6e 20 66 |ember fu|nction f|
|00000090| 6f 72 20 6f 70 65 72 61 | 74 6f 72 20 6f 76 65 72 |or opera|tor over|
|000000a0| 6c 6f 61 64 0a 44 61 74 | 65 3a 20 54 68 75 2c 20 |load.Dat|e: Thu, |
|000000b0| 31 31 20 41 70 72 20 31 | 39 39 36 20 31 34 3a 32 |11 Apr 1|996 14:2|
|000000c0| 38 3a 34 37 20 47 4d 54 | 0a 4f 72 67 61 6e 69 7a |8:47 GMT|.Organiz|
|000000d0| 61 74 69 6f 6e 3a 20 48 | 6f 6d 65 6e 65 74 20 43 |ation: H|omenet C|
|000000e0| 6f 6d 6d 75 6e 69 63 61 | 74 69 6f 6e 73 2c 20 49 |ommunica|tions, I|
|000000f0| 6e 63 0a 4d 65 73 73 61 | 67 65 2d 49 44 3a 20 3c |nc.Messa|ge-ID: <|
|00000100| 34 6b 6a 35 35 6e 24 6d | 76 32 40 68 6f 6d 65 6e |4kj55n$m|v2@homen|
|00000110| 65 74 2e 68 6f 6d 2e 6e | 65 74 3e 0a 52 65 70 6c |et.hom.n|et>.Repl|
|00000120| 79 2d 54 6f 3a 20 64 65 | 6e 67 65 6c 40 68 6f 6d |y-To: de|ngel@hom|
|00000130| 2e 6e 65 74 0a 4e 4e 54 | 50 2d 50 6f 73 74 69 6e |.net.NNT|P-Postin|
|00000140| 67 2d 48 6f 73 74 3a 20 | 64 69 61 6c 69 6e 31 2d |g-Host: |dialin1-|
|00000150| 36 2e 68 6f 6d 2e 6e 65 | 74 0a 4d 69 6d 65 2d 56 |6.hom.ne|t.Mime-V|
|00000160| 65 72 73 69 6f 6e 3a 20 | 31 2e 30 0a 43 6f 6e 74 |ersion: |1.0.Cont|
|00000170| 65 6e 74 2d 54 79 70 65 | 3a 20 74 65 78 74 2f 70 |ent-Type|: text/p|
|00000180| 6c 61 69 6e 3b 20 63 68 | 61 72 73 65 74 3d 55 53 |lain; ch|arset=US|
|00000190| 2d 41 53 43 49 49 0a 43 | 6f 6e 74 65 6e 74 2d 54 |-ASCII.C|ontent-T|
|000001a0| 72 61 6e 73 66 65 72 2d | 45 6e 63 6f 64 69 6e 67 |ransfer-|Encoding|
|000001b0| 3a 20 37 62 69 74 0a 58 | 2d 4e 65 77 73 72 65 61 |: 7bit.X|-Newsrea|
|000001c0| 64 65 72 3a 20 46 6f 72 | 74 65 20 46 72 65 65 20 |der: For|te Free |
|000001d0| 41 67 65 6e 74 20 31 2e | 30 2e 38 32 0a 0a 43 61 |Agent 1.|0.82..Ca|
|000001e0| 6e 20 61 6e 79 6f 6e 65 | 20 74 65 6c 6c 20 6d 65 |n anyone| tell me|
|000001f0| 20 74 68 65 20 72 65 6c | 61 74 69 76 65 20 61 64 | the rel|ative ad|
|00000200| 76 61 6e 74 61 67 65 73 | 20 61 6e 64 20 64 69 73 |vantages| and dis|
|00000210| 61 64 76 61 6e 74 61 67 | 65 73 20 6f 66 20 75 73 |advantag|es of us|
|00000220| 69 6e 67 0a 61 20 66 72 | 69 65 6e 64 20 66 75 6e |ing.a fr|iend fun|
|00000230| 63 74 69 6f 6e 20 76 73 | 2e 20 61 20 6d 65 6d 62 |ction vs|. a memb|
|00000240| 65 72 20 66 75 6e 63 74 | 69 6f 6e 20 74 6f 20 6f |er funct|ion to o|
|00000250| 76 65 72 6c 6f 61 64 20 | 61 6e 20 6f 70 65 72 61 |verload |an opera|
|00000260| 74 6f 72 2c 20 73 75 63 | 68 0a 61 73 20 61 64 64 |tor, suc|h.as add|
|00000270| 69 74 69 6f 6e 3f 20 20 | 46 6f 72 20 65 78 61 6d |ition? |For exam|
|00000280| 70 6c 65 2c 20 73 75 70 | 70 6f 73 65 20 79 6f 75 |ple, sup|pose you|
|00000290| 20 68 61 76 65 20 61 20 | 43 6f 6d 70 6c 65 78 20 | have a |Complex |
|000002a0| 63 6c 61 73 73 20 28 49 | 27 6d 20 6e 6f 74 0a 69 |class (I|'m not.i|
|000002b0| 6e 74 65 72 65 73 74 65 | 64 20 69 6e 20 62 75 69 |ntereste|d in bui|
|000002c0| 6c 64 69 6e 67 20 61 20 | 63 6f 6d 70 6c 65 78 20 |lding a |complex |
|000002d0| 63 6c 61 73 73 2d 2d 49 | 27 6d 20 6a 75 73 74 20 |class--I|'m just |
|000002e0| 75 73 69 6e 67 20 74 68 | 69 73 20 66 6f 72 20 61 |using th|is for a|
|000002f0| 6e 0a 65 78 61 6d 70 6c | 65 2e 29 3a 0a 0a 63 6c |n.exampl|e.):..cl|
|00000300| 61 73 73 20 43 6f 6d 70 | 6c 65 78 20 7b 0a 70 72 |ass Comp|lex {.pr|
|00000310| 69 76 61 74 65 3a 0a 09 | 69 6e 74 20 72 65 61 6c |ivate:..|int real|
|00000320| 2c 20 69 6d 61 67 3b 0a | 2e 20 2e 20 2e 20 0a 7d |, imag;.|. . . .}|
|00000330| 3b 0a 0a 4e 6f 77 2c 20 | 79 6f 75 20 77 6f 75 6c |;..Now, |you woul|
|00000340| 64 20 77 61 6e 74 20 74 | 6f 20 62 65 20 61 62 6c |d want t|o be abl|
|00000350| 65 20 74 6f 20 61 64 64 | 20 63 6f 6d 70 6c 65 78 |e to add| complex|
|00000360| 20 6e 75 6d 62 65 72 73 | 2c 20 6c 69 6b 65 20 73 | numbers|, like s|
|00000370| 6f 3a 0a 0a 43 6f 6d 70 | 6c 65 78 20 61 2c 20 62 |o:..Comp|lex a, b|
|00000380| 2c 20 63 3b 0a 0a 61 20 | 3d 20 28 73 6f 6d 65 20 |, c;..a |= (some |
|00000390| 63 6f 6d 70 6c 65 78 20 | 6e 75 6d 62 65 72 29 3b |complex |number);|
|000003a0| 0a 62 20 3d 20 28 73 6f | 6d 65 20 63 6f 6d 70 6c |.b = (so|me compl|
|000003b0| 65 78 20 6e 75 6d 62 65 | 72 29 3b 0a 63 20 3d 20 |ex numbe|r);.c = |
|000003c0| 61 20 2b 20 62 3b 0a 0a | 4e 6f 77 2c 20 61 73 20 |a + b;..|Now, as |
|000003d0| 66 61 72 20 61 73 20 49 | 20 63 61 6e 20 74 65 6c |far as I| can tel|
|000003e0| 6c 2c 20 74 68 65 72 65 | 20 61 72 65 20 74 77 6f |l, there| are two|
|000003f0| 20 67 65 6e 65 72 61 6c | 20 61 70 70 72 6f 61 63 | general| approac|
|00000400| 68 65 73 20 74 6f 20 74 | 68 69 73 2e 0a 4f 6e 65 |hes to t|his..One|
|00000410| 20 69 73 20 74 68 65 20 | 64 65 63 6c 61 72 65 20 | is the |declare |
|00000420| 61 20 66 72 69 65 6e 64 | 20 66 75 6e 63 74 69 6f |a friend| functio|
|00000430| 6e 20 68 65 61 64 65 72 | 20 69 6e 20 74 68 65 20 |n header| in the |
|00000440| 63 6c 61 73 73 20 64 65 | 66 69 6e 69 74 69 6f 6e |class de|finition|
|00000450| 3a 0a 0a 66 72 69 65 6e | 64 20 43 6f 6d 70 6c 65 |:..frien|d Comple|
|00000460| 78 20 6f 70 65 72 61 74 | 6f 72 2b 28 20 43 6f 6d |x operat|or+( Com|
|00000470| 70 6c 65 78 26 20 61 2c | 20 43 6f 6d 70 6c 65 78 |plex& a,| Complex|
|00000480| 26 20 62 29 20 3b 0a 0a | 61 6e 64 20 74 68 65 6e |& b) ;..|and then|
|00000490| 20 64 65 66 69 6e 65 20 | 74 68 61 74 20 66 75 6e | define |that fun|
|000004a0| 63 74 69 6f 6e 20 73 6f | 6d 65 74 68 69 6e 67 20 |ction so|mething |
|000004b0| 6c 69 6b 65 3a 0a 0a 43 | 6f 6d 70 6c 65 78 20 6f |like:..C|omplex o|
|000004c0| 70 65 72 61 74 6f 72 2b | 28 20 43 6f 6d 70 6c 65 |perator+|( Comple|
|000004d0| 78 26 20 63 6f 6e 73 74 | 20 61 2c 20 43 6f 6d 70 |x& const| a, Comp|
|000004e0| 6c 65 78 26 20 63 6f 6e | 73 74 20 62 29 20 7b 0a |lex& con|st b) {.|
|000004f0| 09 43 6f 6d 70 6c 65 78 | 20 74 65 6d 70 3b 0a 09 |.Complex| temp;..|
|00000500| 74 65 6d 70 2e 72 65 61 | 6c 20 3d 20 61 2e 72 65 |temp.rea|l = a.re|
|00000510| 61 6c 20 2b 20 62 2e 72 | 65 61 6c 3b 0a 09 74 65 |al + b.r|eal;..te|
|00000520| 6d 70 2e 69 6d 61 67 20 | 3d 20 61 2e 69 6d 61 67 |mp.imag |= a.imag|
|00000530| 20 2b 20 62 2e 69 6d 61 | 67 3b 0a 09 72 65 74 75 | + b.ima|g;..retu|
|00000540| 72 6e 20 74 65 6d 70 3b | 0a 7d 0a 0a 54 68 65 20 |rn temp;|.}..The |
|00000550| 6f 74 68 65 72 20 77 61 | 79 20 69 73 20 74 6f 20 |other wa|y is to |
|00000560| 70 75 74 20 74 68 65 20 | 6f 70 65 72 61 74 6f 72 |put the |operator|
|00000570| 20 69 6e 20 74 68 65 20 | 63 6c 61 73 73 20 64 65 | in the |class de|
|00000580| 66 69 6e 69 74 69 6f 6e | 20 69 74 73 65 6c 66 3a |finition| itself:|
|00000590| 0a 0a 43 6f 6d 70 6c 65 | 78 20 6f 70 65 72 61 74 |..Comple|x operat|
|000005a0| 6f 72 2b 28 20 43 6f 6d | 70 6c 65 78 26 20 63 6f |or+( Com|plex& co|
|000005b0| 6e 73 74 20 61 29 20 7b | 0a 09 43 6f 6d 70 6c 65 |nst a) {|..Comple|
|000005c0| 78 20 74 65 6d 70 3b 0a | 09 74 65 6d 70 2e 72 65 |x temp;.|.temp.re|
|000005d0| 61 6c 20 3d 20 74 68 69 | 73 2d 3e 72 65 61 6c 20 |al = thi|s->real |
|000005e0| 2b 20 61 2e 72 65 61 6c | 3b 0a 09 74 65 6d 70 2e |+ a.real|;..temp.|
|000005f0| 69 6d 61 67 20 3d 20 74 | 68 69 73 2d 3e 69 6d 61 |imag = t|his->ima|
|00000600| 67 20 2b 20 61 2e 69 6d | 61 67 3b 0a 09 72 65 74 |g + a.im|ag;..ret|
|00000610| 75 72 6e 20 74 65 6d 70 | 3b 0a 7d 0a 0a 43 61 6e |urn temp|;.}..Can|
|00000620| 20 61 6e 79 6f 6e 65 20 | 74 65 6c 6c 20 6d 65 20 | anyone |tell me |
|00000630| 69 66 20 6f 6e 65 20 6f | 66 20 74 68 65 73 65 20 |if one o|f these |
|00000640| 74 68 65 20 22 70 72 65 | 66 65 72 72 65 64 22 20 |the "pre|ferred" |
|00000650| 77 61 79 20 6f 66 20 64 | 6f 69 6e 67 20 69 74 3f |way of d|oing it?|
|00000660| 0a 41 6e 64 2c 20 77 68 | 61 74 20 61 72 65 20 74 |.And, wh|at are t|
|00000670| 68 65 20 61 64 76 61 6e | 74 61 67 65 73 20 61 6e |he advan|tages an|
|00000680| 64 20 64 69 73 61 64 76 | 61 6e 74 61 67 65 73 20 |d disadv|antages |
|00000690| 6f 66 20 65 61 63 68 3f | 0a 0a 54 68 61 6e 6b 73 |of each?|..Thanks|
|000006a0| 2e 0a 0a 2d 2d 0a 44 61 | 6e 20 45 6e 67 65 6c 20 |...--.Da|n Engel |
|000006b0| 28 64 65 6e 67 65 6c 40 | 68 6f 6d 2e 6e 65 74 29 |(dengel@|hom.net)|
|000006c0| 0a 0a | |.. | |
+--------+-------------------------+-------------------------+--------+--------+